package print;

import java.io.*;

//打印流可以实现方便高效的打印数据都文件中，并且可以指定字符编码
public class printDemo1 {
    public static void main(String[] args) throws IOException {
        System.err.println("错误信息");
        PrintStream ps=new PrintStream("G:\\Javatest2\\print\\printDemo1.txt","gbk");
        ps.print("97");
        ps.print("a");
        ps.println("b");
        ps.println("c");
        ps.println("d");
        ps.close();
//        开启追加写入
        PrintStream ps2=new PrintStream(new FileOutputStream("G:\\Javatest2\\print\\1.txt",true));
        ps2.println("你好");
        ps2.close();
//        autoflush:true设置自动刷新
        PrintWriter pw=new PrintWriter(new FileWriter("G:\\Javatest2\\print\\2.txt",true),true);
        pw.println("你好");
        pw.println("hello");

    }
}
